<?php

namespace App\Http\Controllers\Front;

use App\Http\Controllers\Controller;
use App\Services\Form\initFormData as InitFormData;
use Illuminate\Http\Request;

class About extends Controller
{

    public function __construct(Request $request, InitFormData $formData)
    {
        $this->request = $request;
        $this->formData = $formData;
        $this->breadMenuInfo = config('front.bread_menu');

    }

    public function index()
    {
        $viewData = [
            'seo' => $this->returnSeoInfo('about_tanwin_index'),
            'selectedMenu' => parent::MENU_ABOUT,
            'left_menu' => 'index',
        ];
        return view('web.about.index', $viewData);
    }

    public function indexMobile()
    {
        $viewData = [
            'seo' => $this->returnSeoInfo('about_tanwin_index'),
            'selectedMenu' => parent::MENU_ABOUT,
        ];
        return view('mobile.about.index', $viewData);
    }

    public function tanwinFamily()
    {
        $viewData = [
            'seo' => $this->returnSeoInfo('about_tanwin_index'),
            'selectedMenu' => parent::MENU_ABOUT,
            'left_menu' => 'index',
        ];
        return view('web.about.tanwin', $viewData);
    }

    public function partnerFamily()
    {
        $viewData = [
            'seo' => $this->returnSeoInfo('about_tanwin_index'),
            'selectedMenu' => parent::MENU_ABOUT,
            'left_menu' => 'index',
        ];
        return view('web.about.partner', $viewData);
    }

    public function partnerFamilyMobile()
    {
        $viewData = [
            'seo' => $this->returnSeoInfo('m_about'),
            'selectedMenu' => parent::MENU_ABOUT,
            'left_menu' => 'index',
        ];
        return view('mobile.about.partnerFamily', $viewData);
    }

    public function newsList()
    {
        $result = $this->formData->getNewsList($this->request, parent::CODE_GET_ARTICLE_LIST);

        $dataList = $result ? $result['dataList'] : [];
        $pageCount = $dataList ? $result['pageCount'] : 1;

        if ($this->request->method() == 'POST') {
            $viewData = [
                'dataList' => $dataList,
            ];
            return view('web.about.ceil.news', $viewData);
        } else {
            $viewData = [
                'seo' => $this->returnSeoInfo(parent::TAB_MENU_ABOUT_TANWIN_NEWS),
                'selectedMenu' => parent::MENU_ABOUT,
                'dataList' => $dataList,
                'pageCount' => $pageCount,
                'left_menu' => 'news',
            ];
            return view('web.about.news', $viewData);
        }
    }

    public function newsInfo()
    {
        $result = $this->formData->getNewsInfo($this->request, parent::CODE_GET_NEWS_INFO);
        $viewData = [
            'seo' => $this->returnSeoInfo(parent::TAB_MENU_ABOUT_TANWIN_NEWS, $result['newsInfo']['title']),
            'selectedMenu' => parent::MENU_ABOUT,
            'dataInfo' => $result['newsInfo'],
        ];
        return view('web.about.news_info', $viewData);
    }

    public function contactUs()
    {
        $viewData = [
            'seo' => $this->returnSeoInfo('about_tanwin_contact'),
            'selectedMenu' => parent::MENU_ABOUT,
            'left_menu' => 'contact',
        ];
        return view('web.about.contact', $viewData);
    }
}
